﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using PPI.Client;
using PPI.Client.Logic.Inspection;
using PPI.Client.Utils;
using PPI.Entities.Inspections;
using VMind.Global;

namespace PPIControls.Map
{
    public partial class InspectionFilter : UserControl
    {
        private List<EInspectionTypes> m_InspectionTypes;
        private List<EResultType> m_InspectionResultTypes;

        public InspectionFilter()
        {
            InitializeComponent();
        }

        public void LoadList()
        {
            m_InspectionTypes = LCacheDataSingleton.Instance.InspectionTypes;
            m_InspectionResultTypes = LCacheDataSingleton.Instance.ResultTypes;
            DropdownHelper.FillListBox(lstInspectionType, m_InspectionTypes, typeof(EInspectionTypes), "Name", "Id", "");
            DropdownHelper.FillListBox(lstInspectionResults, m_InspectionResultTypes, typeof(EResultType), "Name", "Id", "");
        }

        public void ClearSelectedItems()
        {
            DropdownHelper.ResetComboIndex(lstInspectionType);
            DropdownHelper.ResetComboIndex(lstInspectionResults);
        }

        public List<EInspectionTypes> SelectedInspectionTypes()
        {
            List<EInspectionTypes> returnInspectionTypes = new List<EInspectionTypes>();

            foreach (ListBoxItem item in lstInspectionType.SelectedItems)
            {
                returnInspectionTypes.Add(new EInspectionTypes(ConvertHelper.ToInt32(item.Value), item.Text));
            }
            return returnInspectionTypes;

        }

        public List<EResultType> SelectedInspectionResults()
        {
            List<EResultType> returnInspectionResults = new List<EResultType>();

            foreach (ListBoxItem item in lstInspectionResults.SelectedItems)
            {
                returnInspectionResults.Add(new EResultType(ConvertHelper.ToInt32(item.Value),item.Text));
            }
            return returnInspectionResults;
        }

        public bool IsElectrical()
        {
            return chkElectrical.Checked;
        }
    }
}
